﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ChargingSystem4.EUc
{
    public partial class UC_ControlUI : UserControl
    {


        private string _MyClientIpPort { get; set; }
        public string MyClientIpPort
        {
            get { return _MyClientIpPort; }
            set
            {
                _MyClientIpPort = value;
            }
        }



        private string _MyState { get; set; }
        public string MyState
        {
            get { return _MyState; }
            set
            {
                label3.Text = value;
                _MyState = value;

                ///"在线";  //离线 
                if (value == "在线")
                {
                    label3.BackColor = Color.Green;
                }
                else if (value == "离线")
                {
                    label3.BackColor = Color.Red;
                } 
            }
        }

        public int MyType { get; set; } = 0;

        private string _MyCode { get; set; }
        public string MyCode
        {
            get { return _MyCode; }
            set
            {

                string showCode = "";
                if (value.Length > 10)
                {
                    showCode = value.Substring(0, 5) + "****" + value.Substring(value.Length - 6, 5);
                }

                label1.Text = showCode;
                _MyCode = value;
            }
        }


        private string _MyName { get; set; }
        public string MyName { get { return _MyName; } set { label2.Text = value; _MyName = value; } }



        public UC_ControlUI()
        {
            InitializeComponent();
        }

        public UC_ControlUI(string codeId, string codeName, int state = 0)
        {
            InitializeComponent();
            MyName = codeName;
            MyCode = codeId;
            this.BackColor = Color.White;
        }

        private void label2_Click(object sender, EventArgs e)
        {
            MyClick();
        }



        private void UC_ControlUI_Click(object sender, EventArgs e)
        {
            MyClick();
        }


        public delegate void delegateHander(object sender, EventArgs e);
        public event delegateHander SetItem;

        private void panel1_Click(object sender, EventArgs e)
        {
            MyClick();
        }
        public void InitColorYellow()
        {
            this.BackColor = Color.Yellow;
        }
        public void MyClick()
        {
            SetItem(this, null);

        }
        public void InitColor()
        {
            this.BackColor = Color.White;
        }

        private void label1_Click(object sender, EventArgs e)
        {
            MyClick();
        }

        private void label3_Click(object sender, EventArgs e)
        {
            MyClick();
        }
    }
}
